/*3nDRqDpPN2aBwSiX3SKSl1vv0nX99Xolh3vt/Oo7y1NmlR5j/iG4DvbVu5Z+Sjnh*/
/*
 * @Descripttion:
 * @version:
 * @Author: Chendch
 * @Date: 2021-10-19 14:13:30
 * @LastEditors: Chendch
 * @LastEditTime: 2021-11-04 19:32:24
 */
import {isObject} from "./typeRegUtil";
//校验对象中某个属性是否存在
function checkPropExist(attrStr, parent) {
  try{
    let level = 1;
    function loop(obj) {
      let prop = attrStr.split(".")[level];
      if(!prop) {
        return true;
      }
      if(obj.hasOwnProperty(prop)) {
        obj = obj[prop];
        level += 1;
        let res = isObject(obj) ? loop(obj) : () => {};
        return res;
      }else if(obj === undefined || !Object.keys(obj).length){
        return false;
      }
    }
    let status = loop(parent);
    return status;
  }catch(e) {
    return undefined;
  }
}

export {
  checkPropExist
}
/*3nDRqDpPN2aBwSiX3SKSl1vv0nX99Xolh3vt/Oo7y1NmlR5j/iG4DvbVu5Z+Sjnh*/
